Translation Service Documentation
This is the Translation Service
Paths
/translation/api/v1/healthz
GET /translation/api/v1/healthz
Summary: Health
Description: Return Health Status.
Responses:
- 200: Successful Response
- Content: application/json
- Schema: Msg
/translation/api/v1/docs
POST /translation/api/v1/docs
Summary: Generate Translation
Description: Generate translation for the provided source text into the specified target language.
Request Body:
Type | Parameter | Description | Data Type | is_optional |
---|---|---|---|---|
Query Parameter | source_text | Text to be translated. | string | mandatory |
Query Parameter | model | Model to be used for translation. | string (enum) | mandatory |
Query Parameter | target_language | Language to translate the text into. | string (enum) | mandatory |
Query Parameter | file_name | Name of the file being translated. | string | optional |
Sample Code:
import requests
# Define the API endpoint and the payload
url = "https://api-genai-dev.learningmate.co/translation/api/v1/text"
headers = {
"accept": "application/json",
"Authorization": "Bearer {Your Token Here}", # Replace {Your Token Here} with your actual token
"Content-Type": "application/x-www-form-urlencoded"
}
data = {
"source_text": "Hello, How are you?",
"target_language": "Hindi",
"model": "gpt-4o-mini"
}
# Make the POST request
response = requests.post(url, headers=headers, data=data)
# Print the response
if response.status_code == 200:
print("Response Data:", response.json())
else:
print("Failed to call the API. Status Code:", response.status_code)
print("Response Text:", response.text)
Example response:
{
"status_code": 200,
"message": "Success: Translation generated successfully.",
"translation": "Translated text here"
}
Responses:
Status Code | Description | Content-Type | Details |
---|---|---|---|
200 | Translation generated | application/json | Successful Response - Status retrieved successfully |
400 | Bad Request | application/json | Bad Request - Invalid format |
401 | Authentication failed | application/json | Unauthorized - Invalid or missing authentication token |
404 | Model not found | application/json | Model not found - Invalid model. |
422 | Validation Error | application/json | Schema: HTTPValidationError |
500 | Internal server error | application/json | An error occurred while generating the translation : [error details]. |
Components
Schemas
- Msg
- TranslationRequest
- HTTPValidationError